{include_core file="lib/header.html" center="center" title="帐号安全"}
{include_core file="lib/top_nav.html" }
      <div class="container">
        <div class="inner">
          <div class="con-top clearfix">
            {include_core file="lib/sidebar.html" crumbs_1="account" crumbs_2="account_safety"}
            <div class="bundling">
              <div class="bundling-list">
                <ul>
                  {if $edit_type == 'edit_password'}
                  <li>
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe1.png"/></h4>
                      <p class="bund-txt">账号密码</p>
                      <p class="bund-txt2">用于保护账号信息和登录安全</p>
                    </div>
                    <form action="{AnUrl('user/setting/password_save')}" id="js_submitBtn" method="post">
                      <div class="bund-label">
                        <input type="hidden" name="edit_type" value="{$edit_type}">
                        <label><span>原密码</span><input type="password" id="jsPassword" name="old_password"/></label>
                        <label><span>新密码</span><input type="password" id="jsnewPassword" name="new_password"/></label>
                        <label><span>确认密码</span><input type="password" id="jsrePassword" name="re_password"/></label>
                      </div>
                      <div class="bund-btn">
                        <a class="bund-bc" href="javascript:void(0);">保存</a>
                        <a class="bund-back" href="{AnUrl('user/setting/account_safety')}">取消</a>
                      </div>
                    </form>
                  </li>
                  <script type="text/javascript">
                    $(function(){
                      $('.bund-bc').click(function(){
                        var pass = $.trim($('#jsPassword').val());
                        var newpass = $.trim($('#jsnewPassword').val());
                        var repass = $.trim($('#jsrePassword').val());
                        if(newpass == '') {
                          showMsg('对不起，新密码不得为空');
                          return ;
                        }
                        if(repass == '') {
                          showMsg('对不起，确认密码不得为空');
                          return ;
                        }
                        if(getStringLen(newpass) < 6) {
                          showMsg('对不起，密码最少要6位字符');
                          return ;
                        }
                        if(getStringLen(newpass) >= 20) {
                          showMsg('对不起，密码最多要20位字符');
                          return ;
                        }
                        if(newpass != repass) {
                          showMsg('对不起，两次输入密码不一致');
                          return ;
                        }
                        $.post(
                          "{AnUrl('user/setting/password_save')}",
                         { 'old_password':pass, 'new_password':newpass, 're_password':repass, 'edit_type':'edit_password' },
                         function(data){
                          if(data.info == 'error') {
                            showMsg(data.msg);
                            return;
                          } else {
                            $('#js_submitBtn').submit();
                          }
                         },'json');
                      });
                    });
                  </script>
                  {elseif $edit_type == 'set_password'}
                  <li class="clearfix">
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe1-1.png"/></h4>
                      <p class="bund-txt">账号密码（未设置）</p>
                      <p class="bund-txt2">用于保护账号信息和登录安全</p>
                    </div>
                    <form action="{AnUrl('user/setting/password_save')}" id="js_submitBtn" method="post">
                      <div class="bund-label">
                        <input type="hidden" name="edit_type" value="{$edit_type}">
                        <label><span>输入密码</span><input type="password" id="jsnewPassword" name="new_password"/></label>
                        <label><span>确认密码</span><input type="password" id="jsrePassword" name="re_password"/></label>
                      </div>
                      <div class="bund-btn">
                        <button class="bund-bc">保存</button>
                        <a class="bund-back" href="{AnUrl('user/setting/account_safety')}">取消</a>
                      </div>
                    </form>
                  </li>
                  <script type="text/javascript">
                    $(function(){
                      $('.bund-bc').click(function(){
                        var newpass = $.trim($('#jsnewPassword').val());
                        var repass = $.trim($('#jsrePassword').val());
                        if(newpass == '') {
                          showMsg('对不起，新密码不得为空');
                          return ;
                        }
                        if(repass == '') {
                          showMsg('对不起，确认密码不得为空');
                          return ;
                        }
                        if(getStringLen(newpass) < 6) {
                          showMsg('对不起，密码最少要6位字符');
                          return ;
                        }
                        if(getStringLen(newpass) >= 20) {
                          showMsg('对不起，密码最多要20位字符');
                          return ;
                        }
                        if(newpass != repass) {
                          showMsg('对不起，两次输入密码不一致');
                          return ;
                        }
                        $.post(
                          "{AnUrl('user/setting/password_save')}",
                         { 'new_password':newpass, 're_password':repass, 'edit_type':'set_password' },
                         function(data){
                          if(data.info == 'error') {
                            showMsg(data.msg);
                            return;
                          } else {
                            $('#js_submitBtn').submit();
                          }
                         },'json');
                      });
                    })
                  </script>
                  {elseif $edit_type == 'edit_email' || $edit_type == 'set_email'}
                  <li>
                    {if $edit_type == 'edit_email'} 
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe2.png"/></h4>
                      <p class="bund-txt">原安全邮箱：{$user_info.email}</p>
                      <p class="bund-txt2">安全邮箱可以用于登录NBD账号，找回密码</p>
                    </div>
                    {elseif $edit_type == 'set_email'}
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe2-1.png"/></h4>
                      <p class="bund-txt">新安全邮箱（未绑定）</p>
                      <p class="bund-txt2">安全邮箱可以用于登录NBD账号，找回密码</p>
                    </div>
                    {/if}
                    <div class="bund-label bund-label2">
                      <label><span>新安全邮箱</span><input type="text" name="new_email" id="js_new_email"/></label>
                    </div>
                    <div class="bund-btn">
                      <a class="bund-bc" href="javascript:void(0);" id="btnEmail">保存</a>
                      <a class="bund-back" href="{AnUrl('user/setting/account_safety')}">取消</a>
                    </div>
                  </li>
                  <script type="text/javascript">
                  $(function(){
                    $('#btnEmail').click(function(){
                        var new_email = $.trim($('#js_new_email').val());
                        if(new_email == '') {
                          showMsg('您输入的邮箱不能为空', 'error');
                          return;
                        }
                        if(!checkStr(new_email, 'mail')) {
                          showMsg('您输入的邮箱格式不正确', 'error');
                          return;
                        }
                        $.post("{AnUrl('user/setting/email_bind')}",
                              { new_email:new_email },
                              function(data){
                                if(data.info == 'error') {
                                  showMsg(data.msg, 'error');
                                  return;
                                } else if(data.info == 'ok') {
                                  $('#js_check_email').html(new_email);
                                  $('.pup-fc').show();
                                  $('.bund-mail').show();
                                }
                              },'json'
                          );

                    });
                    $('.bund-close').click(function(){
                        $('.pup-fc').hide();
                        $('.bund-mail').hide();
                    });
                  });
                  </script>
                  {elseif $edit_type == 'edit_mobile'}
                  <li>
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe3.png"/></h4>
                      <p class="bund-txt">安全手机：{$user_info.mobile}</p>
                      <p class="bund-txt2">安全手机可以用于登录NBD账号，找回密码</p>
                    </div>
                    <form action="{AnUrl('user/setting/check_sms')}" id="js_edit_mobile" method="post">
                      <div class="bund-label bund-label2">
                        <input type="hidden" value="edit" name="send_type" />
                        <label class="bund-num"><span>验证码</span><input type="text" id="js_code" name="code"/><a href="javascript:void(0);" id="getCode" value="on">获取验证码</a></label>
                      </div>
                      <div class="bund-btn">
                        <a class="bund-bc" href="javascript:void(0);" id="edit_mobile">保存</a>
                        <a class="bund-back" href="{AnUrl('user/setting/account_safety')}">取消</a>
                      </div>
                    </form>
                  </li>
                  <script type="text/javascript">
                  $(function(){
                    $('#getCode').click(function(){
                      // var mobile = $.trim($('#js_mobileM').val());
                      // var codeNext = $('#js_codeM').parent().next();
                        if($(this).attr('value') == 'on') {
                        $.post(
                            "{AnUrl('user/register/sendRegsms')}",
                            { 'mobile':{$user_info.mobile}, 'send_type':'edit' },
                            function(data){
                              if(data.info == 'error') {
                                showMsg(data.msg, 'error');
                              } else {
                                var time = 59;
                                $('#getCode').html(time).attr('value', 'off');
                                var Timer=setInterval(function(){
                                  if(time > 0){
                                    time--;
                                    $('#getCode').html(time).attr('value', 'off');
                                  } else {
                                    $('#getCode').html('获取验证码').attr('value', 'on');
                                    clearInterval(Timer);
                                  }
                                },1000);
                              }
                            },'json');
                        }
                    });
                    $('#edit_mobile').click(function(){
                      var code = $.trim($('#js_code').val());
                      if(code == '') {
                        showMsg('手机验证码不能为空！');
                        return;
                      }
                      $.post(
                          "{AnUrl('user/setting/check_sms')}",
                          { 'code':code, 'send_type':'edit' },
                          function(data) {
                            if(data.info == 'error') {
                              showMsg(data.msg, 'error');
                              return;
                            } else {
                              $('#js_edit_mobile').submit();
                            }
                          },'json');
                    });
                  });
                  </script>
                  {elseif $edit_type == 'set_mobile'}
                  <li>
                    <div class="bund-passw clearfix">
                      <h4><img src="{$smarty.const.STATIC_URL}/images/safe3-1.png"/></h4>
                      <p class="bund-txt">安全手机</p>
                      <p class="bund-txt2">安全手机可以用于登录NBD账号，找回密码</p>
                    </div>
                    <form action="{AnUrl('user/setting/check_sms')}" id="js_check_mobile" method="post">
                      <div class="bund-label bund-label2">
                        <input type="hidden" name="send_type" value="check" />
                        <label><span>新安全手机</span><input type="text" id="js_mobile" name="mobile"/></label>
                        <label class="bund-num"><span>验证码</span><input type="text" id="js_code" name="code"/><a href="javascript:void(0);" id="getCode" value="on">获取验证码</a></label>
                      </div>
                      <div class="bund-btn">
                        <a class="bund-bc" href="javascript:void(0);" id="check_mobile">保存</a>
                        <a class="bund-back" href="{AnUrl('user/setting/account_safety')}">取消</a>
                      </div>
                    </form>
                  </li>
                  <script type="text/javascript">
                  $(function(){
                    $('#getCode').click(function(){
                      var mobile = $.trim($('#js_mobile').val());
                      if(mobile == '') {
                        showMsg('手机号码不能为空！', 'error');
                        return;
                      }
                      if(!checkStr(mobile, 'mobile')) {
                        showMsg('手机号码的格式不正确！', 'error');
                        return;
                      }
                      $.post(
                          "{AnUrl('user/register/ajax_mobile')}",
                          { mobile:mobile },
                          function(data) {
                            if(data.info == 'error') {
                              showMsg(data.msg);
                              return;
                            } else {
                              if($('#getCode').attr('value') == 'on') {
                                var time = 59;
                                $('#getCode').html(time).attr('value', 'off');
                                var Timer=setInterval(function(){
                                  if(time > 0){
                                    time--;
                                    $('#getCode').html(time).attr('value', 'off');
                                  } else {
                                    $('#getCode').html('获取验证码').attr('value', 'on');
                                    clearInterval(Timer);
                                  }
                                },1000);

                                $.post(
                                  "{AnUrl('user/register/sendRegsms')}",
                                  { 'mobile':mobile, 'send_type':'check' },
                                  function(data){
                                    if(data.info == 'error') {
                                      showMsg(data.msg, 'error');
                                    } else {
                                      var time = 59;
                                      $('#getCode').html(time).attr('value', 'off');
                                      var Timer=setInterval(function(){
                                        if(time > 0){
                                          time--;
                                          $('#getCode').html(time).attr('value', 'off');
                                        } else {
                                          $('#getCode').html('获取验证码').attr('value', 'on');
                                          clearInterval(Timer);
                                        }
                                      },1000);
                                    }
                                  },'json');
                              }
                            }
                          },'json'
                      );
                    });

                    $('#check_mobile').click(function(){
                      var mobile = $.trim($('#js_mobile').val());
                      var code = $.trim($('#js_code').val());
                      if(mobile == '') {
                        showMsg('手机号码不能为空！', 'error');
                      }
                      if(!checkStr(mobile, 'mobile')) {
                        showMsg('手机号码的格式不正确！', 'error');
                      }
                      if(code == '') {
                        showMsg('手机验证码不能为空！', 'error');
                        return;
                      }
                      $.post(
                          "{AnUrl('user/setting/check_sms')}",
                          { 'code':code, 'mobile' : mobile, 'send_type':'check' },
                          function(data) {
                            if(data.info == 'error') {
                              showMsg(data.msg, 'error');
                              return;
                            } else {
                              $('#js_check_mobile').submit();
                            }
                          },'json');
                    });

                  });
                  </script>
                  {/if}
                </ul>
              </div>
              <!--bundling-list已绑定修改  end-->
            </div>
            <!--bundling  end-->
          </div>
          <!--con-top  end-->
        </div>
        <!--inner  end-->
      </div>
      <!--container  end-->
      <div class="pup-fc hidden"></div>
      <div class="bund-mail hidden">
        <div class="bund-close"><a href="javascript:void(0);"><img src="{$smarty.const.STATIC_URL}/images/close3.png"/></a></div>
        <div class="mail-txt">
          <p>系统已发送了一份激活邮件到您的邮箱</p>
          <p>请访问您的邮箱：<a href="javascript:void(0);" id="js_check_email"></a>，点击邮件中的链接便可激活您的账号</p>
        </div>
        <div class="bund-user"><a href="{AnUrl('user/setting/account_safety')}">验证完成</a></div>
      </div>
{include_core file="lib/footer.html"}